﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
using System.Collections.Generic;

namespace Jy123.Web.Module.Venues
{
    public partial class VenuesModel : System.Web.UI.Page
    {
        protected string StrLevel;
        protected void Page_Load(object sender, EventArgs e)
        {
            BindHtml();
        }

        private void BindHtml()
        {
            string key = "Level";
            string levelString = Request.QueryString[key];
            if (!string.IsNullOrEmpty(levelString))
            {
                StrLevel = levelString;
                int levelId = int.Parse(levelString);

                Jy123.BLL.Public_Level BLLLevel = new Jy123.BLL.Public_Level();
                Jy123.Model.Public_Level level = BLLLevel.GetModel(levelId);
                string strWhere = string.Format("FJType = {0} ORDER BY LevelNumber ASC", level.FJType.Value);
                List<Jy123.Model.Public_Level> listLevel = BLLLevel.GetModelList(strWhere);
                string strHtml = Cache["venuesmodel"].ToString();
                StringBuilder strbuilderLi = new StringBuilder();
                foreach (Jy123.Model.Public_Level cLevel in listLevel)
                {
                    string strLi = Cache["venuesmodelli"].ToString();
                    strLi = strLi.Replace("$LiId$", "modelLi" + cLevel.LevelNumber.Value.ToString());
                    if (cLevel.LevelNumber.Value == level.LevelNumber.Value)
                    {
                        strLi = strLi.Replace("$Class$", "Infobtn");
                    }
                    else
                    {
                        strLi = strLi.Replace("$Class$", "");
                    }
                    strLi = strLi.Replace("$ClickEvent$", string.Format("fillhtml('venuesModelDiv','/Module/Venues/VenuesModel.aspx?Level={0}&'+ Math.random())", cLevel.ID));
                    strLi = strLi.Replace("$Content$", cLevel.LName);
                    strbuilderLi.Append(strLi);
                }
                strHtml = strHtml.Replace("$VenuesModelLi$", strbuilderLi.ToString());
                strHtml = strHtml.Replace("$ShowVenuesName$", level.LName);
                string modelString = level.Model;
                if (string.IsNullOrEmpty(modelString))
                {
                    modelString = "/Images/Module/QC2playground.jpg";
                }
                strHtml = strHtml.Replace("$showVenuesImgSrc$", modelString);
                StringBuilder strAnnexeLi = new StringBuilder();
                Jy123.BLL.Annexe.Annexe BLLAnnexe = new Jy123.BLL.Annexe.Annexe();
                List<Jy123.Model.Public_Annexe> listAnnexe = BLLAnnexe.AnnexeListCanUse(level);
                foreach (Jy123.Model.Public_Annexe annexe in listAnnexe)
                {
                    string uvLi = Cache["updatevenuesli"].ToString();
                    uvLi = uvLi.Replace("$LiContent$", annexe.AName);
                    strAnnexeLi.Append(uvLi);
                }
                strHtml = strHtml.Replace("$ShowVenuesAnnexeLi$", strAnnexeLi.ToString());
                Response.Write(strHtml);
            }
        }
    }
}
